﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TTDataAccess;
using TTEntity;
using System.Data;

namespace TTBusiness
{
    public class clsBSComment
    {
        clsDAComment objDA = new clsDAComment();
        private clsComment getDataFromRow(DataRow dr)
        {
            try
            {
                clsComment obj = new clsComment();
                if (!dr.Equals(null))
                {
                    if (!dr.IsNull("ID"))
                        obj.Id = Convert.ToInt32(dr["ID"]);
                    if (!dr.IsNull("ProductID"))
                        obj.ProductId = Convert.ToInt32(dr["ProductID"]);
                    if (!dr.IsNull("AccountID"))
                        obj.AccountId = Convert.ToInt32(dr["AccountID"]);
                    if (!dr.IsNull("Detail"))
                        obj.Detail = dr["Detail"].ToString();
                    if (!dr.IsNull("Status"))
                        obj.Status = Convert.ToBoolean(dr["Status"]);
                    if (!dr.IsNull("AdminID"))
                        obj.AdminId = Convert.ToInt32(dr["AdminID"]);
                }
                return obj;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public List<clsComment> getAll()
        {
            try
            {

                List<clsComment> objList = new List<clsComment>();
                DataTable dt = new DataTable();
                dt = objDA.GetAll();
                foreach (DataRow dr in dt.Rows)
                {
                    clsComment account = new clsComment();
                    account = getDataFromRow(dr);
                    objList.Add(account);
                }
                return objList;
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Insert(clsComment obj)
        {
            try
            {
                objDA.Insert(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Update(clsComment obj)
        {
            try
            {
                objDA.Update(obj);
            }
            catch (Exception)
            {

                throw;
            }
        }
        public void Delete(int id)
        {
            try
            {
                objDA.Delete(id);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
